import java.awt.*;
import java.awt.datatransfer.*;
import java.awt.dnd.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.*;


public class TradeUI extends JFrame {
	
	private JPanel contentPane;
	private JLabel largeDeedLabel;
	private JButton cancelButton, resetButton, tradeDoneButton;
	private JButton[] testLabels;
	private DragSource dragSource;
	private DragGestureRecognizer[] dragRecognizers;
	private Block[] block;
	

	private Player playerOne, playerTwo;
	private JPanel playerOnePanel = null,  playerTwoPanel = null;
	private JTextField playerOneTextField, playerTwoTextField;
	private JScrollPane playerOneScrollPane = null, playerTwoScrollPane = null;
	private DropTarget dropTargetPlayerOnePanel, dropTargetPlayerTwoPanel, dropTargerLargeDeed;
	private JButton[] playerOneDeeds, playerTwoDeeds;
	private JLabel playerOneCurrentMoneyLabel, playerTwoCurrentMoneyLabel;
	Object object;
	
	static final DataFlavor[] supportedFlavors = {null};
    
    static {
        try {
            supportedFlavors[0] = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
	
	
	public TradeUI(Block[] block, Player playerOne, Player[] players){
		
		//get parameters
		this.block = block;
		this.playerOne = playerOne;
		Player[] tempPlayers = players;
		this.setVisible(true);
		
		
		
		//set frame
		this.setTitle("Trade");
		this.setBounds(100,100,770,480);
		this.contentPane = new ImagePanel(new ImageIcon("Graphics/TradeUIBG.png").getImage());
		//this.contentPane = new JPanel();
		this.setContentPane(contentPane);
		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		JLabel label = new JLabel("Dito ang pera");
		label.setBounds(59, 417, 100, 14);
		contentPane.add(label);
		
		JLabel label_1 = new JLabel("Dito ang pera");
		label_1.setBounds(600, 417, 100, 14);
		contentPane.add(label_1);
		getContentPane().setLayout(null);
		
			//SET COMPONENTS
		
		this.setPlayerPanels();
		
		//initialize Components
		this.playerOneTextField = new JTextField();
		this.playerTwoTextField = new JTextField();
		this.largeDeedLabel = new JLabel(new ImageIcon("Graphics/defcard.png"));
		this.resetButton = new JButton(new ImageIcon("Graphics/resetButton.png"));
		this.cancelButton = new JButton(new ImageIcon("Graphics/cancelButton.png"));
		this.tradeDoneButton = new JButton(new ImageIcon("Graphics/tradeDoneButton.png"));
		this.playerOneCurrentMoneyLabel = new JLabel(this.playerOne.getCurrentMoney()+"");
		
		
		
		//add to contentPane
		getContentPane().add(this.playerOneTextField);
		getContentPane().add(this.playerTwoTextField);
		getContentPane().add(this.largeDeedLabel);
		getContentPane().add(this.resetButton);
		getContentPane().add(this.cancelButton);
		getContentPane().add(this.tradeDoneButton);
		getContentPane().add(this.playerOneCurrentMoneyLabel);
		
		
		//setBound
		this.largeDeedLabel.setBounds(290, 20, 170, 200);
		this.playerOneTextField.setBounds(20, 380, 250, 25);
		this.playerTwoTextField.setBounds(480, 380, 250, 25);
		this.resetButton.setBounds(305, 240, 50, 50);
		this.cancelButton.setBounds(395, 240, 50, 50);
		this.tradeDoneButton.setBounds(275, 290 ,200, 125);
		this.playerOneCurrentMoneyLabel.setBounds(20, 400, 170, 25);
		
		
		//set design
		this.setImageButton(this.cancelButton, "Graphics/cancelButtonRollOver.png");
		this.setImageButton(this.resetButton, "Graphics/resetButtonRollOver.png");
		this.setImageButton(this.tradeDoneButton, "Graphics/tradeDoneButtonRollOver.png");
		this.resetButton.setToolTipText("Umulit");
		this.cancelButton.setToolTipText("Ipagpaliban");
		this.tradeDoneButton.setToolTipText("Tapos");
			
			//end
		
		
			//action listeners
		
		this.resetButton.addActionListener(new ActionListener(){

			
			@Override
			public void actionPerformed(ActionEvent e) {
				
				/*
				playerOnePanel.setVisible(false);
				playerTwoPanel.setVisible(false);
				playerOneScrollPane.setVisible(false);
				playerTwoScrollPane.setVisible(false);
				
				setPlayerPanels();*/
				
				playerOnePanel.removeAll();
				playerTwoPanel.removeAll();
				playerOnePanel.revalidate();
				playerTwoPanel.revalidate();
				playerOnePanel.updateUI();
				playerTwoPanel.updateUI();
				setPlayerDeeds();
				
				
			}
			
		});
		
		this.tradeDoneButton.addActionListener(new DoneSequence());
		this.cancelButton.addActionListener(new ActionListener(){

			
			@Override
			public void actionPerformed(ActionEvent e) {
				
				disposeMethod();
			}
			
			
			
		});
			//end
		
			//set Drop Targets
		
		this.dragSource = new DragSource();
		this.dropTargerLargeDeed = new DropTarget(this.largeDeedLabel, DnDConstants.ACTION_MOVE, new DropTargetClassForLargeDeed());
		
			
			//end
		
			
		//choose player to trade
		ChoosePlayerDialog dialog = new ChoosePlayerDialog(this, tempPlayers);
		this.setEnabled(false);
		
			
		
		
	}
	
	private void setButtonDragSource(JButton[] button){
		
		this.dragRecognizers = new DragGestureRecognizer[button.length];
		
		for(int counter = 0 ; counter<button.length;counter++){
			
			this.dragRecognizers[counter] = dragSource.createDefaultDragGestureRecognizer(button[counter], DnDConstants.ACTION_MOVE, new DragGestureClass());
				
		}
		
	}
	
	public void disposeMethod(){
		
		this.dispose();
		
	}
	
	
	public void setPlayerPanels(){
		
		this.playerOnePanel = new JPanel();
		this.playerOnePanel.setLayout(null);
		this.playerTwoPanel = new JPanel();
		this.playerTwoPanel.setLayout(null);
		
		this.playerOnePanel.setBackground(Color.WHITE);
		this.playerTwoPanel.setBackground(Color.WHITE);
		
		this.playerOneScrollPane = new JScrollPane(this.playerOnePanel,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		this.playerTwoScrollPane = new JScrollPane(this.playerTwoPanel,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		
		this.playerOnePanel.setPreferredSize(new Dimension(250,1000));
		this.playerTwoPanel.setPreferredSize(new Dimension(250,1000));
		
		getContentPane().add(this.playerOneScrollPane);
		getContentPane().add(this.playerTwoScrollPane);
		
		this.playerOneScrollPane.setBounds(20, 20, 250, 350);
		this.playerTwoScrollPane.setBounds(480, 20, 250, 350);
		
		this.dropTargetPlayerOnePanel =  new DropTarget(this.playerOnePanel, DnDConstants.ACTION_MOVE, new DropTargetClass());
		this.dropTargetPlayerTwoPanel =  new DropTarget(this.playerTwoPanel, DnDConstants.ACTION_MOVE, new DropTargetClass());
		
		
		this.playerOneScrollPane.setVisible(true);
		this.playerTwoScrollPane.setVisible(true);
		
		
	}
	
	public void setPlayerDeeds(){
		
		
		//segregate blocks by two button arraysList
		ArrayList<JButton> playerOneBlocks = new ArrayList<JButton>();
		ArrayList<JButton> playerTwoBlocks = new ArrayList<JButton>();
		
		for(int counter = 0; counter <this.block.length; counter++){
			
			if(block[counter] instanceof PropertyBlock){
				
				if(((PropertyBlock) block[counter]).getCOwner() != null){
					
					if(((PropertyBlock) block[counter]).getCOwner().equals(this.playerOne)){
							
						JButton button = new JButton(new ImageIcon(((PropertyBlock) block[counter]).getPropertyDeedSmall()));
						button.setName(""+counter);
						playerOneBlocks.add(button);
							
					}else if(((PropertyBlock) block[counter]).getCOwner().equals(this.playerTwo)){
						
						JButton button = new JButton(new ImageIcon(((PropertyBlock) block[counter]).getPropertyDeedSmall()));
						button.setName(""+counter);
						playerTwoBlocks.add(button);
						
					}
				
				}
				
			}else if(block[counter] instanceof RailRoad){
				
				if(((RailRoad) block[counter]).getCOwner()!= null){
					
					if(((RailRoad) block[counter]).getCOwner().equals(this.playerOne)){
						
						JButton button = new JButton(new ImageIcon(((RailRoad) block[counter]).getPropertyDeedSmall()));
						button.setName(""+counter);
						playerOneBlocks.add(button);
						
					}else if(((RailRoad) block[counter]).getCOwner().equals(this.playerTwo)){
						
						JButton button = new JButton(new ImageIcon(((RailRoad) block[counter]).getPropertyDeedSmall()));
						button.setName(""+counter);
						playerTwoBlocks.add(button);
						
					}
					
				}
				
			}else if(block[counter] instanceof Utilities){
				
				if(((Utilities) block[counter]).getCOwner() != null){
				
					if(((Utilities) block[counter]).getCOwner().equals(this.playerOne)){
						
						JButton button = new JButton(new ImageIcon(((Utilities) block[counter]).getPropertyDeedSmall()));
						button.setName(""+counter);
						playerOneBlocks.add(button);
						
					}else if(((Utilities) block[counter]).getCOwner().equals(this.playerTwo)){
						
						JButton button = new JButton(new ImageIcon(((Utilities) block[counter]).getPropertyDeedSmall()));
						button.setName(""+counter);
						playerTwoBlocks.add(button);
						
					}
					
				}
				
			}
			
		}
		
		//to array the arraylist
		
		this.playerOneDeeds = playerOneBlocks.toArray(new JButton[playerOneBlocks.size()]);
		this.playerTwoDeeds = playerTwoBlocks.toArray(new JButton[playerTwoBlocks.size()]);
		
		
		for(int counter = 0; counter<playerOneDeeds.length; counter++){
			
			this.playerOnePanel.add(this.playerOneDeeds[counter]);
			
		}
		for(int counter = 0; counter<playerTwoDeeds.length; counter++){
			
			this.playerTwoPanel.add(this.playerTwoDeeds[counter]);
			
		}
		
		setButtonDragSource(this.playerOneDeeds);
		setButtonDragSource(this.playerTwoDeeds);
		
		this.arrangeLabels(this.playerOnePanel);
		this.arrangeLabels(this.playerTwoPanel);
		
		
		
		
	}
	
	public void updatePlayerTwo(){
		
		this.playerTwoCurrentMoneyLabel = new JLabel(this.playerTwo.getCurrentMoney()+"");
		getContentPane().add(this.playerTwoCurrentMoneyLabel);
		this.playerTwoCurrentMoneyLabel.setBounds(480, 400, 170, 25);
		
	}
	
	private void arrangeLabels(JPanel panel){
		
		Component[] test =  panel.getComponents();
		panel.setPreferredSize(new Dimension(250,350));
		
		
		for(int counter = 0, x = 8, y = 10; counter<test.length; counter++){
			
			test[counter].setBounds(x, y, 68, 80);
			//System.out.println(x+","+y);
			if(x != 150){
				
				x= x+71;
				//System.out.println("1");
			}else{
				
				x = 8;
				y = y+85;
				
				//System.out.println("2");
			}
			
		}
		
	}
	
	public Cursor getCursor(Component component){
    	
    	Cursor cursor;
    	
    	Toolkit toolkit = Toolkit.getDefaultToolkit();
    	Image image = null;
    	if(block[Integer.parseInt(component.getName())] instanceof PropertyBlock){
    		
    		image = toolkit.getImage(((PropertyBlock) block[Integer.parseInt(component.getName())]).getPropertyDeedSmall());
    	
    	}else if(block[Integer.parseInt(component.getName())] instanceof RailRoad){
    		
    		image = toolkit.getImage(((RailRoad) block[Integer.parseInt(component.getName())]).getPropertyDeedSmall());
    		
    	}else if(block[Integer.parseInt(component.getName())] instanceof Utilities){
    		
    		image = toolkit.getImage(((Utilities) block[Integer.parseInt(component.getName())]).getPropertyDeedSmall());
    		
    	}
 
    	image = image.getScaledInstance(13, 24, Image.SCALE_SMOOTH);
    	cursor = toolkit.createCustomCursor(image , new Point(0,0), "img");
    	System.out.println(component.getName());
    	System.out.println(toolkit.getBestCursorSize(68, 80));
    	
    	
    	return cursor;
    	
    	
    }

	private void setImageButton(JButton button, String rollOverPath){
		
		button.setBorderPainted(false);
		button.setContentAreaFilled(false);
		button.setOpaque(false);
		button.setRolloverEnabled(true);
		button.setRolloverIcon(new ImageIcon(rollOverPath));
		
	}
	
	private class DragGestureClass implements DragGestureListener{

		
		@Override
		public void dragGestureRecognized(DragGestureEvent ev) {
	        ev.startDrag(getCursor(ev.getComponent()), new TrasferableClass(), new DragSourceClass());
	    }
		
	}
	
	public class DragSourceClass implements DragSourceListener{

		 @Override
		public void dragDropEnd(DragSourceDropEvent ev) {
		    }
		    @Override
			public void dragEnter(DragSourceDragEvent ev) {
		    }
		    @Override
			public void dragExit(DragSourceEvent ev) {
		    }
		    @Override
			public void dragOver(DragSourceDragEvent ev) {
		        object = ev.getSource();
		    }
		    @Override
			public void dropActionChanged(DragSourceDragEvent ev) {
		    }
		
	}
	
	private class DropTargetClass implements DropTargetListener{

		 @Override
		public void dragEnter(DropTargetDragEvent ev) {
		    }
		    @Override
			public void dragExit(DropTargetEvent ev) {
		    }
		    @Override
			public void dragOver(DropTargetDragEvent ev) {
		        dropTargetDrag(ev);
		    }
		    @Override
			public void dropActionChanged(DropTargetDragEvent ev) {
		        dropTargetDrag(ev);
		    }
		    void dropTargetDrag(DropTargetDragEvent ev) {
		    	
		    	
		    	
		    }
		    @Override
			public void drop(DropTargetDropEvent ev) {
		        ev.acceptDrop(ev.getDropAction());
		        try {
		            Object target = ev.getSource();
		            Object source = ev.getTransferable().getTransferData(supportedFlavors[0]);
		            Component component = ((DragSourceContext)source).getComponent();
		            Container oldContainer = component.getParent();
		            Container container = (Container) ((DropTarget) target).getComponent();
		            container.add(component);
		            oldContainer.validate();
		            oldContainer.repaint();
		            container.validate();
		            container.repaint();
		            arrangeLabels((JPanel) container.getDropTarget().getComponent());
		            arrangeLabels((JPanel) oldContainer.getDropTarget().getComponent());
		        } 
		        catch (Exception ex) {
		            ex.printStackTrace();
		        }
		        ev.dropComplete(true);
		    }
		
		
		
	}
	
	private class DropTargetClassForLargeDeed implements DropTargetListener{

		 @Override
		public void dragEnter(DropTargetDragEvent ev) {
		    }
		    @Override
			public void dragExit(DropTargetEvent ev) {
		    }
		    @Override
			public void dragOver(DropTargetDragEvent ev) {
		        dropTargetDrag(ev);
		    }
		    @Override
			public void dropActionChanged(DropTargetDragEvent ev) {
		        dropTargetDrag(ev);
		    }
		    void dropTargetDrag(DropTargetDragEvent ev) {
		    	
		    	
		    	
		    }
		    @Override
			public void drop(DropTargetDropEvent ev) {
		        ev.acceptDrop(ev.getDropAction());
		        try {
		            Object target = ev.getSource();
		            Object source = ev.getTransferable().getTransferData(supportedFlavors[0]);
		            Component component = ((DragSourceContext)source).getComponent();
		            Container oldContainer = component.getParent();
		            Container container = (Container) ((DropTarget) target).getComponent();
		            container.setVisible(false);
		            if(block[Integer.parseInt(component.getName())] instanceof PropertyBlock){
		        		
		        		container = new JLabel(new ImageIcon(((PropertyBlock) block[Integer.parseInt(component.getName())]).getPropertyDeedLarge()));
		        	
		        	}else if(block[Integer.parseInt(component.getName())] instanceof RailRoad){
		        		
		        		container = new JLabel(new ImageIcon(((RailRoad) block[Integer.parseInt(component.getName())]).getPropertyDeedLarge()));
		        		
		        	}else if(block[Integer.parseInt(component.getName())] instanceof Utilities){
		        		
		        		container = new JLabel(new ImageIcon(((Utilities) block[Integer.parseInt(component.getName())]).getPropertyDeedLarge()));
		        		
		        	}
		            contentPane.add(container);
		            container.setBounds(290, 20, 170, 200);
		            container.setVisible(true);
		            dropTargerLargeDeed = new DropTarget(container, DnDConstants.ACTION_MOVE, this);
		            oldContainer.validate();
		            oldContainer.repaint();
		            container.validate();
		            container.repaint();
		        } 
		        catch (Exception ex) {
		            ex.printStackTrace();
		        }
		        ev.dropComplete(true);
		    }
		
		
		
	}
	
	private class TrasferableClass implements Transferable{

		@Override
		public Object getTransferData(DataFlavor flavor) {
	        if (flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType)) {
	            return object;
	        } else {
	            return null;
	        }	
	    }

		 @Override
		public DataFlavor[] getTransferDataFlavors() {
		        return supportedFlavors;
		 }
		    
		    @Override
			public boolean isDataFlavorSupported(DataFlavor flavor) {
		        return flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType);
		 }
	
	}
	
	private class ChoosePlayerDialog extends JDialog {

		private final JPanel contentPanel = new JPanel();
		private JButton[] playerIcons;
		private TradeUI frame;

		public ChoosePlayerDialog(TradeUI tradeUI, Player[] tempPlayers) {
			Player[] players;
			ArrayList<Player> playerArrayList = new ArrayList<Player>();
			
			for(int counter = 0; counter<tempPlayers.length; counter++){
				
				if(tempPlayers[counter].getActive()){
					
					playerArrayList.add(tempPlayers[counter]);
					
				}
				
			}
			
			players = new Player[playerArrayList.size()];
			
			playerArrayList.toArray(players);
			
			this.frame = tradeUI;
			this.frame.setEnabled(false);
			this.setBounds(100, 100, 150, 225);
			getContentPane().setLayout(new FlowLayout());
			this.contentPanel.setLayout(new FlowLayout());
			this.setContentPane(this.contentPanel);
			this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
			this.addButtons(players);
			this.setVisible(true);
			
		}
		
		public void addButtons(Player[] players){
			
			playerIcons = new JButton[players.length-1];
			
			for(int playerCounter = 0, buttonCounter = 0; playerCounter<players.length; playerCounter++){
				
				if(!playerOne.equals(players[playerCounter])){
					playerIcons[buttonCounter] = new JButton(new ImageIcon(players[playerCounter].getPlayerToken()));
					this.contentPanel.add(playerIcons[buttonCounter]);
					playerIcons[buttonCounter].setToolTipText(players[playerCounter].getPlayerName());
					playerIcons[buttonCounter].setSize(68, 80);
					playerIcons[buttonCounter].addActionListener(new ButtonListener(players[playerCounter]));
					playerIcons[buttonCounter].setVisible(true);
					buttonCounter++;
				}
				
			}
			
		}
		
		private class ButtonListener implements ActionListener{
			
			Player pointer;
			
			public ButtonListener(Player pointer){
				
				this.pointer = pointer;
				endMethod();
				
			}
			
			@Override
			public void actionPerformed(ActionEvent e) {
				
				playerTwo = pointer;
				updatePlayerTwo();
				setPlayerDeeds();
				endMethod();
				
			}
			
		}
		
		public void endMethod(){
			
			this.frame.setEnabled(true);
			this.dispose();
			
		}
		
		

	}
	
	
	private boolean isTextFieldFilled(JTextField textField){
		
		boolean returnValue = true;
		
		if(textField.getText().isEmpty())
			returnValue = false;
			
		
		return returnValue;
		
	}
	
	private boolean isCapableOfPaying(JTextField textField, Player p){
		
		boolean returnValue = true;
		try{
		if(Integer.parseInt(textField.getText()) > p.getCurrentMoney())
			returnValue = false;
		}catch(Exception e){JOptionPane.showMessageDialog(null, "Nag-Error: Hindi pwede ang nilagay mong tawad.");}
		
		return returnValue;
		
	}
	
	private class DoneSequence implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			
			doneSequence();
			
		}
		
		
	}
	
	public void doneSequence(){
		
		if(isTextFieldFilled(playerOneTextField) && !isTextFieldFilled(playerTwoTextField)){
			
			if(isCapableOfPaying(playerOneTextField, playerOne)){
				
				playerTwo.addMoney(Integer.parseInt(playerOneTextField.getText()));
				playerOne.subtractMoney(Integer.parseInt(playerOneTextField.getText()));
				transferDeeds();
				this.dispose();
				
				
			}else{JOptionPane.showMessageDialog(null, "Kulang pero mo O hindi pwede ang nilagay mo");
				return;}
			
		}else if(!isTextFieldFilled(playerOneTextField) && isTextFieldFilled(playerTwoTextField)){
			
			if(isCapableOfPaying(playerTwoTextField, playerTwo)){
				
				playerOne.addMoney(Integer.parseInt(playerTwoTextField.getText()));
				playerTwo.subtractMoney(Integer.parseInt(playerTwoTextField.getText()));
				transferDeeds();
				this.dispose();
				
			}else{JOptionPane.showMessageDialog(null, "Kulang pero mo O hindi pwede ang nilagay mo");
				return;}
			
		}else if(!isTextFieldFilled(playerOneTextField) && !isTextFieldFilled(playerTwoTextField)){
			
			transferDeeds();
			this.dispose();
				
		}else{
			
			JOptionPane.showMessageDialog(null, "Parehong may laman ang lalagyanan ng pera, maaring nakalimutan mong ito'y blanko dapat o pareho kayong mag bibigay ng pera.");
			
		}
		
	}
	
	public void transferDeeds(){
		
		Object[] objOne = this.playerOnePanel.getComponents();
		Object[] objTwo = this.playerTwoPanel.getComponents();
		
		for(int counter = 0; counter<objOne.length; counter++){
			
			if(block[Integer.parseInt(((Component) objOne[counter]).getName())] instanceof PropertyBlock){
				
				((PropertyBlock) block[Integer.parseInt(((Component) objOne[counter]).getName())]).setCOwner(this.playerOne);
				
			}else if(block[Integer.parseInt(((Component) objOne[counter]).getName())] instanceof RailRoad){
				
				((RailRoad) block[Integer.parseInt(((Component) objOne[counter]).getName())]).setCOwner(this.playerOne);
				
			}else if(block[Integer.parseInt(((Component) objOne[counter]).getName())] instanceof Utilities){
				
				((Utilities) block[Integer.parseInt(((Component) objOne[counter]).getName())]).setCOwner(this.playerOne);
				
			}
			
		}
		
		for(int counter = 0; counter<objTwo.length; counter++){
			
			if(block[Integer.parseInt(((Component) objTwo[counter]).getName())] instanceof PropertyBlock){
				
				((PropertyBlock) block[Integer.parseInt(((Component) objTwo[counter]).getName())]).setCOwner(this.playerTwo);
				
			}else if(block[Integer.parseInt(((Component) objTwo[counter]).getName())] instanceof RailRoad){
				
				((RailRoad) block[Integer.parseInt(((Component) objTwo[counter]).getName())]).setCOwner(this.playerTwo);
				
			}else if(block[Integer.parseInt(((Component) objTwo[counter]).getName())] instanceof Utilities){
				
				((Utilities) block[Integer.parseInt(((Component) objTwo[counter]).getName())]).setCOwner(this.playerTwo);
				
			}
			
		}
		
		/**
		 if(block[Integer.parseInt(component.getName())] instanceof PropertyBlock){
    		
    		image = toolkit.getImage(((PropertyBlock) block[Integer.parseInt(component.getName())]).getPropertyDeedSmall());
    	
    	}else if(block[Integer.parseInt(component.getName())] instanceof RailRoad){
    		
    		image = toolkit.getImage(((RailRoad) block[Integer.parseInt(component.getName())]).getPropertyDeedSmall());
    		
    	}else if(block[Integer.parseInt(component.getName())] instanceof Utilities){
    		
    		image = toolkit.getImage(((Utilities) block[Integer.parseInt(component.getName())]).getPropertyDeedSmall());
    		
    	}
		 */
		
	}
}